package cn.zhfeat.core.core;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class SpringApplicationContextHolderUtil implements ApplicationContextAware {
    private static ApplicationContext context;
    
    @Override  
    public void setApplicationContext(ApplicationContext context)
            throws BeansException {
        SpringApplicationContextHolderUtil.context = context;
    }  
  
    public static Object getSpringBean(String beanName) {  
        return context == null ? null : context.getBean(beanName);  
    }  
  
    public static String[] getBeanDefinitionNames() {  
        return context.getBeanDefinitionNames();  
    }
}